<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>Date对象 | H5笔记</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-expandable-chapters/expandable-chapters.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-splitter/splitter.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../../md/js/理解对象.html" />
    
    
    <link rel="prev" href="../../md/gulp/gulp.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="6.1"
        data-chapter-title="Date对象"
        data-filepath="md/js/js_date_obj.md"
        data-basepath="../.."
        data-revision="Tue Mar 13 2018 17:15:57 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Introduction
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="md/html/html.html">
            
                
                    <a href="../../md/html/html.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        Html知识
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="md/html/table.html">
            
                
                    <a href="../../md/html/table.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        表格
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="md/html/a.html">
            
                
                    <a href="../../md/html/a.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        a标签
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="md/html/anchor.html">
            
                
                    <a href="../../md/html/anchor.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.1.</b>
                        
                        a标签锚点
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="md/html/base.html">
            
                
                    <a href="../../md/html/base.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.2.</b>
                        
                        base标签
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="md/html/icon.html">
            
                
                    <a href="../../md/html/icon.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.3.</b>
                        
                        icon
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="md/html/img.html">
            
                
                    <a href="../../md/html/img.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        图片
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="md/html/picture.html">
            
                
                    <a href="../../md/html/picture.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.1.</b>
                        
                        picture标签
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="md/html/hotmap.html">
            
                
                    <a href="../../md/html/hotmap.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.2.</b>
                        
                        热区
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="md/html/video.html">
            
                
                    <a href="../../md/html/video.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.3.</b>
                        
                        视频
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="md/html/audio.html">
            
                
                    <a href="../../md/html/audio.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.4.</b>
                        
                        音频
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="md/html/tabulation.html">
            
                
                    <a href="../../md/html/tabulation.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        列表
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="md/html/ul.html">
            
                
                    <a href="../../md/html/ul.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.1.</b>
                        
                        无序列表
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="md/html/dl.html">
            
                
                    <a href="../../md/html/dl.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.2.</b>
                        
                        无序列表2
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="md/html/ol.html">
            
                
                    <a href="../../md/html/ol.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.3.</b>
                        
                        有序列表
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="md/html/sz.html">
            
                
                    <a href="../../md/html/sz.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.5.</b>
                        
                        实体字符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="md/html/iframe.html">
            
                
                    <a href="../../md/html/iframe.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.6.</b>
                        
                        iframe标签
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="md/html/form.html">
            
                
                    <a href="../../md/html/form.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.7.</b>
                        
                        form表单
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="md/html/tz.html">
            
                
                    <a href="../../md/html/tz.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.8.</b>
                        
                        拓展
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="md/css/css.html">
            
                
                    <a href="../../md/css/css.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        CSS
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="md/css/ys.html">
            
                
                    <a href="../../md/css/ys.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        元素选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="md/css/id-class.html">
            
                
                    <a href="../../md/css/id-class.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        id和class选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="md/css/relationship-selector.html">
            
                
                    <a href="../../md/css/relationship-selector.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        关系选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="md/css/w.html">
            
                
                    <a href="../../md/css/w.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        伪类选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="md/css/attribute-selectors.html">
            
                
                    <a href="../../md/css/attribute-selectors.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        属性选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="md/css/w2.html">
            
                
                    <a href="../../md/css/w2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                        伪对象选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="md/css/font.html">
            
                
                    <a href="../../md/css/font.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.7.</b>
                        
                        字体
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="md/css/color.html">
            
                
                    <a href="../../md/css/color.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.8.</b>
                        
                        元素颜色
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.9" data-path="md/css/text-shadow.html">
            
                
                    <a href="../../md/css/text-shadow.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.9.</b>
                        
                        文本阴影
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.9.1" data-path="md/css/textdecoration.html">
            
                
                    <a href="../../md/css/textdecoration.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.9.1.</b>
                        
                        文本的线
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.9.2" data-path="md/cs/vertical-align.html">
            
            <span><b>2.9.2.</b> 文本垂直对齐</span>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.10" data-path="md/css/box.html">
            
                
                    <a href="../../md/css/box.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.10.</b>
                        
                        盒子
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.10.1" data-path="md/css/zhu.html">
            
                
                    <a href="../../md/css/zhu.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.10.1.</b>
                        
                        行内元素和块级元素
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.10.2" data-path="md/css/float.html">
            
                
                    <a href="../../md/css/float.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.10.2.</b>
                        
                        浮动
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.10.3" data-path="md/css/flex.html">
            
                
                    <a href="../../md/css/flex.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.10.3.</b>
                        
                        弹性盒子
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.11" data-path="md/css/location.html">
            
                
                    <a href="../../md/css/location.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.11.</b>
                        
                        定位
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.12" data-path="md/css/exercise.html">
            
                
                    <a href="../../md/css/exercise.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.12.</b>
                        
                        练习
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="md/gitbook/use.html">
            
                
                    <a href="../../md/gitbook/use.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        gitbook使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4" data-path="md/scss/scss.html">
            
                
                    <a href="../../md/scss/scss.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        Sass使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5" data-path="md/gulp/gulp.html">
            
                
                    <a href="../../md/gulp/gulp.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        Gulp
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6" data-path="md/js.html">
            
            <span><b>6.</b> JS</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="6.1" data-path="md/js/js_date_obj.html">
            
                
                    <a href="../../md/js/js_date_obj.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        Date对象
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="md/js/理解对象.html">
            
                
                    <a href="../../md/js/理解对象.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                        理解对象
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="md/js/事件.html">
            
                
                    <a href="../../md/js/事件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.</b>
                        
                        事件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="md/js/XMLHttpRequest对象.html">
            
                
                    <a href="../../md/js/XMLHttpRequest对象.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.4.</b>
                        
                        AJAX
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../" >H5笔记</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h3 id="jsdate&#x5BF9;&#x8C61;">JS-Date&#x5BF9;&#x8C61;</h3>
<p><strong><code>Date</code>&#x5BF9;&#x8C61;&#x57FA;&#x4E8E;1970&#x5E74;1&#x6708;1&#x65E5;(&#x4E16;&#x754C;&#x6807;&#x51C6;&#x65F6;&#x95F4;)&#x8D77;&#x7684;&#x6BEB;&#x79D2;&#x6570;</strong></p>
<ol>
<li>&#x51FD;&#x6570;&#x7684;&#x5EFA;&#x7ACB;</li>
</ol>
<pre><code class="lang-html">    var myDate = new Date();
</code></pre>
<p>2.&#x6BCF;&#x4E2A;&#x5BF9;&#x8C61;&#x7684;&#x89E3;&#x91CA;</p>
<pre><code class="lang-html">    var myDate = new Date();
    myDate.getFullYear();    //&#x83B7;&#x53D6;&#x5B8C;&#x6574;&#x7684;&#x5E74;&#x4EFD;(4&#x4F4D;,1970-????)
    myDate.getMonth();       //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x6708;&#x4EFD;(0-11,0&#x4EE3;&#x8868;1&#x6708;)
    myDate.getDate();        //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x65E5;(1-31)
    myDate.getDay();         //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x661F;&#x671F;X(0-6,0&#x4EE3;&#x8868;&#x661F;&#x671F;&#x5929;)
    myDate.getTime();        //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x65F6;&#x95F4;(&#x4ECE;1970.1.1&#x5F00;&#x59CB;&#x7684;&#x6BEB;&#x79D2;&#x6570;)
    myDate.getHours();       //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x5C0F;&#x65F6;&#x6570;(0-23)
    myDate.getMinutes();     //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x5206;&#x949F;&#x6570;(0-59)
    myDate.getSeconds();     //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x79D2;&#x6570;(0-59)
    myDate.getMilliseconds();    //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x6BEB;&#x79D2;&#x6570;(0-999)
    myDate.toLocaleDateString();     //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x65E5;&#x671F;(&#x9ED8;&#x8BA4;&#x4E3A;&#x672C;&#x5730;&#x7684;)
    var mytime=myDate.toLocaleTimeString();     //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x65F6;&#x95F4;(&#x9ED8;&#x8BA4;&#x4E3A;&#x672C;&#x5730;&#x7684;)
    myDate.toLocaleString();        //&#x83B7;&#x53D6;&#x65E5;&#x671F;&#x4E0E;&#x65F6;&#x95F4;(&#x9ED8;&#x8BA4;&#x4E3A;&#x672C;&#x5730;&#x7684;)
</code></pre>
<p><em><code>getMonth</code>&#x548C;<code>getDay</code>&#x7684;&#x662F;&#x4EE5;&#x2018;0&#x2019;&#x5F00;&#x59CB;&#x7684;&#xFF0C;&#x8981;&#x6B63;&#x5E38;&#x663E;&#x793A;&#x9700;&#x8981;&#x5C06;&#x5176;&#x6362;&#x6210;&#x6570;&#x7EC4;(&#x5982;&#x4E0B;&#x65B9;&#x793A;&#x4F8B;),&#x6216;&#x8005;&#x8FDB;&#x884C;&#x6362;&#x7B97;&#x7B49;&#x5176;&#x4ED6;&#x7684;&#x624B;&#x6BB5;&#x5904;&#x7406;</em></p>
<ol>
<li>&#x6BCF;&#x4E2A;&#x5BF9;&#x8C61;&#x52A0;&#x8BA1;&#x65F6;&#x5668;&#x7684;&#x793A;&#x4F8B;</li>
</ol>
<pre><code class="lang-html">    <span class="hljs-tag">&lt;<span class="hljs-title">div</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">&quot;lock&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">div</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">&quot;haomiao&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">script</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">&quot;text/javascript&quot;</span>&gt;</span><span class="javascript">
            <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">haomiao</span>(<span class="hljs-params"></span>)</span>{
                <span class="hljs-keyword">var</span> d = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>();
                <span class="hljs-keyword">var</span> haomiao = d.getMilliseconds();
                <span class="hljs-keyword">var</span> now =d.toLocaleString();
                <span class="hljs-keyword">var</span> gi = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">&quot;#haomiao&quot;</span>)
                gi.innerHTML = <span class="hljs-string">&quot;&#x6BEB;&#x79D2;&#x6570;&quot;</span>+haomiao+<span class="hljs-string">&quot;&lt;br/&gt;&#x5F53;&#x524D;&#x65E5;&#x671F;&#x548C;&#x65F6;&#x95F4;&quot;</span>+now
            }
            setInterval(<span class="hljs-string">&quot;haomiao()&quot;</span>,<span class="hljs-number">1</span>)
            <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">ref</span>(<span class="hljs-params"></span>)</span>{
                <span class="hljs-keyword">var</span> month=[<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>,<span class="hljs-number">6</span>,<span class="hljs-number">7</span>,<span class="hljs-number">8</span>,<span class="hljs-number">9</span>,<span class="hljs-number">10</span>,<span class="hljs-number">11</span>,<span class="hljs-number">12</span>]
                <span class="hljs-keyword">var</span> week = [<span class="hljs-string">&quot;&#x65E5;&quot;</span>,<span class="hljs-string">&quot;&#x4E00;&quot;</span>,<span class="hljs-string">&quot;&#x4E8C;&quot;</span>,<span class="hljs-string">&quot;&#x4E09;&quot;</span>,<span class="hljs-string">&quot;&#x56DB;&quot;</span>,<span class="hljs-string">&quot;&#x4E94;&quot;</span>,<span class="hljs-string">&quot;&#x516D;&quot;</span>]
                <span class="hljs-keyword">var</span> getid = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">&quot;#lock&quot;</span>);
                <span class="hljs-keyword">var</span> myDate = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>();
                <span class="hljs-keyword">var</span> year = myDate.getFullYear();
                <span class="hljs-keyword">var</span> mou = month[myDate.getMonth()];
                <span class="hljs-keyword">var</span> tian = myDate.getDate();
                <span class="hljs-keyword">var</span> day = week[myDate.getDay()];
                <span class="hljs-keyword">var</span> hh = myDate.getHours();
                <span class="hljs-keyword">var</span> mm = myDate.getMinutes();
                <span class="hljs-keyword">var</span> ss = myDate.getSeconds();
                <span class="hljs-keyword">var</span> now_date = myDate.toDateString();
                <span class="hljs-keyword">var</span> mytime=myDate.toLocaleTimeString();
                getid.innerHTML=<span class="hljs-string">&quot;&#x4ECA;&#x5929;&#x662F;&quot;</span>+year+<span class="hljs-string">&quot;&#x5E74;&quot;</span>+mou+<span class="hljs-string">&quot;&#x6708;&quot;</span>+tian+<span class="hljs-string">&quot;&#x65E5;&quot;</span>+<span class="hljs-string">&quot;&#x5468;&quot;</span>+day+<span class="hljs-string">&apos;&amp;nbsp&apos;</span>+hh+<span class="hljs-string">&quot;&#x65F6;&quot;</span>+mm+<span class="hljs-string">&quot;&#x5206;&quot;</span>+ss+<span class="hljs-string">&quot;&#x79D2;&lt;br/&gt;&quot;</span>+<span class="hljs-string">&quot;&#x5F53;&#x524D;&#x65E5;&#x671F;&quot;</span>+now_date+<span class="hljs-string">&quot;&lt;br/&gt;&#x5F53;&#x524D;&#x65F6;&#x95F4;&quot;</span>+mytime
            }
            setInterval(<span class="hljs-string">&quot;ref()&quot;</span>,<span class="hljs-number">1000</span>);
        </span><span class="hljs-tag">&lt;/<span class="hljs-title">script</span>&gt;</span>
</code></pre>
<p><em>&#x793A;&#x4F8B;</em></p>
<p><div id="lock"></div>
        <div id="haomiao"></div>
        <script type="text/javascript">
            function haomiao(){
                var d = new Date();
                var haomiao = d.getMilliseconds();
                var now =d.toLocaleString();
                var gi = document.querySelector("#haomiao")
                gi.innerHTML = "毫秒数"+haomiao+"<br/>当前日期和时间"+now
            }
            setInterval("haomiao()",1)
            function ref(){
                var month=[1,2,3,4,5,6,7,8,9,10,11,12]
                var week = ["日","一","二","三","四","五","六"]
                var getid = document.querySelector("#lock");
                var myDate = new Date();
                var year = myDate.getFullYear();
                var mou = month[myDate.getMonth()];
                var tian = myDate.getDate();
                var day = week[myDate.getDay()];
                var hh = myDate.getHours();
                var mm = myDate.getMinutes();
                var ss = myDate.getSeconds();
                var now_date = myDate.toDateString();
                var mytime=myDate.toLocaleTimeString();
                getid.innerHTML="今天是"+year+"年"+mou+"月"+tian+"日"+"周"+day+'&nbsp'+hh+"时"+mm+"分"+ss+"秒<br/>"+"当前日期"+now_date+"<br/>当前时间"+mytime
            }
            setInterval("ref()",1000);
        </script></p>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../../md/gulp/gulp.html" class="navigation navigation-prev " aria-label="Previous page: Gulp"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../../md/js/理解对象.html" class="navigation navigation-next " aria-label="Next page: 理解对象"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../../gitbook/app.js"></script>

    
    <script src="../../gitbook/plugins/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-splitter/splitter.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-livereload/plugin.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"expandable-chapters":{},"redirect":{},"splitter":{},"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"livereload":{}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
